package com.learn.springcloud.eurekahaprovider.controller;

import com.learn.springcloud.eurekahaprovider.bean.Users;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @Time : 2018/7/23 19:40
 * @Version : 1.0
 * @Author : hongyan.li@hand-china.com
 * Copyright @ 2000 Shanghai Hand Co. Ltd.
 * All right reserved.
 */
@RestController
public class PostProavider {

    @PostMapping(value = "/provider/postForEntity1/service")
    public Users postForEntity1(@RequestBody Users users) {
        if("aaa".equals(users.getName())){
            return new Users("aaa",new Date());
        }else{
            return new Users();
        }
    }


    @PostMapping(value = "/provider/postForEntity2/service")
    public Users postForEntity2(@RequestBody Users users, String anything) {
        System.out.println(anything);
        if("aaa".equals(users.getName())){
            return new Users("aaa",new Date());
        }else{
            return new Users();
        }
    }

    @PostMapping(value = "/provider/postForObject1/service")
    public Date postForObject1(@RequestBody Users users) {
        if("aaa".equals(users.getName())){
            return new Date();
        }else{
            return null;
        }
    }

    @PostMapping(value = "/provider/postForObject2/service")
    public Date postForObject2(@RequestBody Users users, String anything) {
        System.out.println(anything);
        if("aaa".equals(users.getName())){
            return new Date();
        }else{
            return null;
        }
    }

}
